<template>
  <div class="classify">
    <div class="classify_head">
      <div class="classify_head_left">请选择商品分类</div>
      <!-- <div class="classify_head_right" @click="setClass">确定</div> -->
    </div>
    <div class="classify_con">
      <div
        class="classify_list"
        v-for="(item,index) in goods_category_list"
        @click="getClass(item.goods_category_id,item.goods_category_name)"
      >
        <div class="classify_list_left">{{item.goods_category_name}}</div>
        <div class="classify_list_right">
          <i class="iconfont iconrightArrow"></i>
        </div>
      </div>
    </div>
    <div class="classify_footer" @click="toEditshop">新增主营分类</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      offon: true,
      number: 0,
      goods_category_parent_id: 0,
      goods_category_list: [],
      goods_class_name:""
    };
  },
  mounted() {
    this.get_goods_category_list();
  },
  methods: {
    get_goods_category_list() {
      this.appJS.ajax(
        "user.get_goods_category_list",
        "post",
        {
          goods_category_parent_id: this.goods_category_parent_id,
          mask:'none'
        },
        res => {
          if (res.recode == 1) {
            this.goods_category_list = res.data.goods_category_list;
          } else {
            this.$emit("getClass", this.goods_category_parent_id,this.goods_class_name);
            this.goods_category_parent_id = 0;
          }
        }
      );
    },
    // 确定分类
    getClass(goods_category_id,goods_class_name) {
      this.goods_category_parent_id = goods_category_id;
      this.goods_class_name = goods_class_name
      this.get_goods_category_list();
    },
    // 增加分类
    toEditshop() {
      this.$router.push({ path: "/editShop" });
    }
  },
  components: {}
};
</script>

<style lang='less'>
.classify {
  height: calc(100vh - 60px);
  background: #fff;
  width: 100%;
  overflow-y: auto;
  position: relative;
  &::-webkit-scrollbar {
    display: none;
  }
  .classify_head {
    height: 3rem;
    width: 100%;
    padding: 0 0.5rem;
    font-size: 0.9rem;
    color: #fff;
    background: @color;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .classify_head_left {
      height: 100%;
      width: 80%;
      display: flex;
      justify-content: flex-start;
      align-items: center;
    }
    .classify_head_right {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      width: 20%;
      height: 100%;
      padding-right: 0.5rem;
    }
  }
  .classify_footer {
    position: fixed;
    bottom: 0;
    left: 0;
    height: 3rem;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: #fff;
    background: @color;
  }
  .classify_con {
    padding-top: 3rem;
  }
  .classify_list {
    height: 3rem;
    width: 100%;
    padding: 0 0.5rem;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    font-size: 0.8rem;
    border-bottom: 1px solid #efefef;
    transition: 0.4s;
    &:active {
      background: #efefef;
    }
    .classify_list_left {
      height: 100%;
      width: 80%;
      display: flex;
      justify-content: flex-start;
      align-items: center;
    }
    .classify_list_right {
      padding-right: 0.5rem;
      height: 100%;
      width: 20%;
      display: flex;
      justify-content: flex-end;
      align-items: center;
      span {
        font-size: 0.4rem;
        color: #fff;
        opacity: 0;
      }
      img {
        height: 1rem;
        width: 1rem;
      }
    }
    &:last-child {
      border: 0;
    }
  }
}
</style>
